/*
 * Heuristic.h
 *
 *  Created on: May 26, 2012
 *      Author: hugo
 */

#ifndef HEURISTIC_H_
#define HEURISTIC_H_
#include "Instance.h"
#include "Solution.h"
#include "LocalSol.h"
#include "Parser.h"
#include <vector>
typedef pair<int,vector<int> > element;
class Heuristic {
public:
	Heuristic(Instance*);
	virtual ~Heuristic();
	double get_time();
	void start(int);
	Solution *get_best();
	double get_stddev();
private:
	Edge *e_null;
	double time;
	double stddev;
	Instance *instance;
	Solution *best;
	unsigned int seed;
	vector<Edge*> build_pool(unsigned int);
	pair<float,Edge*> eval_node(Vertex*,int);
	pair<float,Edge*> eval_node(Vertex*,int,Solution*);
	Solution* prim(vector<Edge*>);
	Solution* search(int);
	LocalSol* construct(vector<Vertex*> pool,int);
	void localsearch(LocalSol**);
	void mylocalsearch(LocalSol** sol);
	float localsearch2(LocalSol* sol, int*);
	bool include_edge(int id,LocalSol* sol,int* values);
	bool include_vertex(int id,LocalSol* sol,int* values);
	vector<Vertex*> build_pool_vertex(unsigned int);
	vector<Vertex*> build_random_pool_vertex(unsigned int length);
	vector<Vertex*> deep_search(LocalSol*,int,int);
	vector<Vertex*> deep_search(LocalSol*,Vertex*,int);
	vector<Vertex*> perform_deep_search(int*,int,int);
	void best_fit(Solution *sol,vector<Edge*>);
	void build(Solution*,int);
	vector<vector<Edge*> > cycles(LocalSol*);
	vector<vector<Edge*> > cycles_root(LocalSol*,int root,element e);
};

#endif /* HEURISTIC_H_ */
